import { defineConfig } from "vite";
import { svelte } from "@sveltejs/vite-plugin-svelte";
import { resolve } from "path";

const outputDir = resolve(__dirname, "../../backend/app/static/js");

export default defineConfig({
  plugins: [svelte()],
  root: resolve(__dirname, "./"),
  build: {
    outDir: outputDir,
    emptyOutDir: true,
    sourcemap: true,
    rollupOptions: {
      input: resolve(__dirname, "./src/main.js"),
      output: {
        entryFileNames: "main.js",
        chunkFileNames: "chunks/[name]-[hash].js",
        assetFileNames: "assets/[name]-[hash][extname]",
        manualChunks: {
          echarts: ["echarts"]
        }
      }
    }
  }
});
